home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 138
/
Volume 138 Aug 19 2011 - Damaged.iso
/
Games
/
mom_mania.swf
/
scripts
/
mx
/
flash
/
UIMovieClip.as
Wrap
Text File
|
2011-08-19
|
24KB
|
861 lines
package mx.flash
{
import flash.display.DisplayObject;
import flash.display.DisplayObjectContainer;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.geom.Rectangle;
import flash.system.ApplicationDomain;
import mx.core.IDeferredInstantiationUIComponent;
import mx.core.IFlexDisplayObject;
import mx.core.IInvalidating;
import mx.core.IStateClient;
import mx.core.IUIComponent;
import mx.core.UIComponentDescriptor;
import mx.core.mx_internal;
import mx.events.FlexEvent;
import mx.events.MoveEvent;
import mx.events.ResizeEvent;
import mx.events.StateChangeEvent;
import mx.managers.ISystemManager;
import mx.managers.IToolTipManagerClient;
public class UIMovieClip extends MovieClip implements IDeferredInstantiationUIComponent, IToolTipManagerClient, IStateClient
{
private var oldHeight:Number;
protected var _height:Number;
private var _currentState:String;
private var _isPopUp:Boolean = false;
private var _systemManager:ISystemManager;
private var explicitSizeChanged:Boolean = false;
private var _explicitHeight:Number;
private var _toolTip:String;
private var _document:Object;
public var boundingBoxName:String = "boundingBox";
private var _measuredWidth:Number;
private var _tweeningProperties:Array;
protected var _width:Number;
private var _focusPane:Sprite;
private var transitionEndState:String;
private var _percentWidth:Number;
private var stateMap:Object;
private var _descriptor:UIComponentDescriptor;
private var oldY:Number;
private var oldX:Number;
private var validateMeasuredSizeFlag:Boolean = true;
private var _includeInLayout:Boolean = true;
private var _explicitMinWidth:Number;
private var _explicitMaxHeight:Number;
private var _explicitMaxWidth:Number;
private var transitionStartFrame:Number;
private var _measuredMinHeight:Number = 0;
private var _measuredHeight:Number;
private var transitionDirection:Number = 0;
private var _owner:DisplayObjectContainer;
private var _id:String;
private var _parent:DisplayObjectContainer;
private var transitionEndFrame:Number;
private var _percentHeight:Number;
private var _explicitMinHeight:Number;
private var _measuredMinWidth:Number = 0;
private var oldWidth:Number;
private var _explicitWidth:Number;
public function UIMovieClip()
{
validateMeasuredSizeFlag = true;
transitionDirection = 0;
explicitSizeChanged = false;
boundingBoxName = "boundingBox";
_includeInLayout = true;
_isPopUp = false;
_measuredMinHeight = 0;
_measuredMinWidth = 0;
super();
addEventListener(Event.ENTER_FRAME,enterFrameHandler,false,0,true);
}
public function getExplicitOrMeasuredHeight() : Number
{
return !!isNaN(explicitHeight) ? Number(measuredHeight) : Number(explicitHeight);
}
private function validateMeasuredSize() : void
{
if(validateMeasuredSizeFlag)
{
validateMeasuredSizeFlag = false;
_measuredWidth = contentBounds.width;
_measuredHeight = contentBounds.height;
}
}
public function get minHeight() : Number
{
if(!isNaN(explicitMinHeight))
{
return explicitMinHeight;
}
return measuredMinHeight;
}
public function set explicitMaxWidth(param1:Number) : void
{
_explicitMaxWidth = param1;
}
protected function enterFrameHandler(param1:Event) : void
{
var _loc2_:Rectangle = null;
var _loc3_:Number = NaN;
if(explicitSizeChanged)
{
explicitSizeChanged = false;
setActualSize(getExplicitOrMeasuredWidth(),getExplicitOrMeasuredHeight());
}
if(isNaN(oldX))
{
oldX = x;
}
if(isNaN(oldY))
{
oldY = y;
}
if(x != oldX || y != oldY)
{
dispatchMoveEvent();
}
_loc2_ = contentBounds;
if(isNaN(oldWidth))
{
oldWidth = _width = _loc2_.width;
}
if(isNaN(oldHeight))
{
oldHeight = _height = _loc2_.height;
}
if(sizeChanged(_loc2_.width,oldWidth) || sizeChanged(_loc2_.height,oldHeight))
{
_width = _loc2_.width;
_height = _loc2_.height;
validateMeasuredSizeFlag = true;
notifySizeChanged();
dispatchResizeEvent();
}
else if(sizeChanged(width,oldWidth) || sizeChanged(height,oldHeight))
{
dispatchResizeEvent();
}
if(currentLabel && currentLabel.indexOf(":") < 0 && currentLabel != _currentState)
{
_currentState = currentLabel;
}
if(transitionDirection != 0)
{
_loc3_ = currentFrame + transitionDirection;
if(transitionDirection > 0 && _loc3_ >= transitionEndFrame || transitionDirection < 0 && _loc3_ <= transitionEndFrame)
{
gotoAndStop(stateMap[transitionEndState].frame);
transitionDirection = 0;
}
else
{
gotoAndStop(_loc3_);
}
}
}
public function get tweeningProperties() : Array
{
return _tweeningProperties;
}
public function set minHeight(param1:Number) : void
{
explicitMinHeight = param1;
}
public function set id(param1:String) : void
{
_id = param1;
}
public function get explicitMinHeight() : Number
{
return _explicitMinHeight;
}
override public function set height(param1:Number) : void
{
explicitHeight = param1;
}
public function set tweeningProperties(param1:Array) : void
{
_tweeningProperties = param1;
}
public function get focusPane() : Sprite
{
return _focusPane;
}
protected function notifySizeChanged() : void
{
if(parent && parent is IInvalidating)
{
IInvalidating(parent).invalidateSize();
IInvalidating(parent).invalidateDisplayList();
}
}
public function set document(param1:Object) : void
{
_document = param1;
}
public function getExplicitOrMeasuredWidth() : Number
{
return !!isNaN(explicitWidth) ? Number(measuredWidth) : Number(explicitWidth);
}
public function get explicitHeight() : Number
{
return _explicitHeight;
}
public function get percentWidth() : Number
{
return _percentWidth;
}
public function get minWidth() : Number
{
if(!isNaN(explicitMinWidth))
{
return explicitMinWidth;
}
return measuredMinWidth;
}
public function get baselinePosition() : Number
{
return 0;
}
public function get systemManager() : ISystemManager
{
var _loc1_:DisplayObject = null;
var _loc2_:DisplayObjectContainer = null;
var _loc3_:IUIComponent = null;
if(!_systemManager)
{
_loc1_ = root;
if(_loc1_)
{
_systemManager = _loc1_ as ISystemManager;
}
else
{
_loc2_ = parent;
while(_loc2_)
{
_loc3_ = _loc2_ as IUIComponent;
if(_loc3_)
{
_systemManager = _loc3_.systemManager;
break;
}
_loc2_ = _loc2_.parent;
}
}
}
return _systemManager;
}
public function get currentState() : String
{
return _currentState;
}
public function set explicitMinHeight(param1:Number) : void
{
_explicitMinHeight = param1;
notifySizeChanged();
}
override public function get parent() : DisplayObjectContainer
{
return !!_parent ? _parent : super.parent;
}
public function get measuredWidth() : Number
{
validateMeasuredSize();
return _measuredWidth;
}
public function get owner() : DisplayObjectContainer
{
return _owner;
}
protected function get contentBounds() : Rectangle
{
if(boundingBoxName && boundingBoxName != "" && boundingBoxName in this)
{
return this[boundingBoxName].getBounds(this);
}
return getBounds(this);
}
public function get maxWidth() : Number
{
return !!isNaN(explicitMaxWidth) ? Number(10000) : Number(explicitMaxWidth);
}
public function parentChanged(param1:DisplayObjectContainer) : void
{
if(!param1)
{
_parent = null;
}
else if(param1 is IUIComponent || param1 is ISystemManager)
{
_parent = param1;
}
else
{
_parent = param1.parent;
}
}
public function set focusPane(param1:Sprite) : void
{
_focusPane = param1;
}
public function set descriptor(param1:UIComponentDescriptor) : void
{
_descriptor = param1;
}
public function registerEffects(param1:Array) : void
{
}
public function get explicitMinWidth() : Number
{
return _explicitMinWidth;
}
override public function set visible(param1:Boolean) : void
{
setVisible(param1);
}
public function set includeInLayout(param1:Boolean) : void
{
_includeInLayout = param1;
}
public function set explicitHeight(param1:Number) : void
{
_explicitHeight = param1;
explicitSizeChanged = true;
notifySizeChanged();
}
public function set percentWidth(param1:Number) : void
{
_percentWidth = param1;
notifySizeChanged();
}
public function get id() : String
{
return _id;
}
public function set systemManager(param1:ISystemManager) : void
{
_systemManager = param1;
}
public function executeBindings(param1:Boolean = false) : void
{
var _loc2_:Object = null;
var _loc3_:* = undefined;
_loc2_ = descriptor && descriptor.document ? descriptor.document : parentDocument;
_loc3_ = ApplicationDomain.currentDomain.getDefinition("mx.binding.BindingManager");
if(_loc3_ != null)
{
_loc3_.executeBindings(_loc2_,id,this);
}
}
override public function get height() : Number
{
if(!isNaN(_height))
{
return _height;
}
return super.height;
}
public function set minWidth(param1:Number) : void
{
explicitMinWidth = param1;
}
public function set currentState(param1:String) : void
{
var _loc2_:* = null;
var _loc3_:Number = NaN;
var _loc4_:Number = NaN;
var _loc5_:StateChangeEvent = null;
if(param1 == _currentState)
{
return;
}
if(!stateMap)
{
buildStateMap();
}
if(stateMap[param1])
{
_loc2_ = _currentState + "-" + param1 + ":start";
if(stateMap[_loc2_])
{
_loc3_ = stateMap[_loc2_].frame;
_loc4_ = stateMap[_currentState + "-" + param1 + ":end"].frame;
}
if(isNaN(_loc3_))
{
_loc2_ = param1 + "-" + _currentState + ":end";
if(stateMap[_loc2_])
{
_loc3_ = stateMap[_loc2_].frame;
_loc4_ = stateMap[param1 + "-" + _currentState + ":start"].frame;
}
}
if(isNaN(_loc3_))
{
_loc2_ = "*-" + param1 + ":start";
if(stateMap[_loc2_])
{
_loc3_ = stateMap[_loc2_].frame;
_loc4_ = stateMap["*-" + param1 + ":end"].frame;
}
}
if(isNaN(_loc3_))
{
_loc2_ = param1 + "-*:end";
if(stateMap[_loc2_])
{
_loc3_ = stateMap[_loc2_].frame;
_loc4_ = stateMap[param1 + "-*:start"].frame;
}
}
if(isNaN(_loc3_))
{
_loc2_ = _currentState + "-*:start";
if(stateMap[_loc2_])
{
_loc3_ = stateMap[_loc2_].frame;
_loc4_ = stateMap[_currentState + "-*:end"].frame;
}
}
if(isNaN(_loc3_))
{
_loc2_ = "*-" + _currentState + ":end";
if(stateMap[_loc2_])
{
_loc3_ = stateMap[_loc2_].frame;
_loc4_ = stateMap["*-" + _currentState + ":start"].frame;
}
}
if(isNaN(_loc3_))
{
_loc2_ = "*-*:start";
if(stateMap[_loc2_])
{
_loc3_ = stateMap[_loc2_].frame;
_loc4_ = stateMap["*-*:end"].frame;
}
}
if(isNaN(_loc3_) && param1 in stateMap)
{
_loc3_ = stateMap[param1].frame;
}
if(isNaN(_loc3_))
{
return;
}
(_loc5_ = new StateChangeEvent(StateChangeEvent.CURRENT_STATE_CHANGING)).oldState = _currentState;
_loc5_.newState = param1;
dispatchEvent(_loc5_);
if(isNaN(_loc4_))
{
gotoAndStop(_loc3_);
transitionDirection = 0;
}
else
{
if(currentFrame < Math.min(_loc3_,_loc4_) || currentFrame > Math.max(_loc3_,_loc4_))
{
gotoAndStop(_loc3_);
}
else
{
_loc3_ = currentFrame;
}
transitionStartFrame = _loc3_;
transitionEndFrame = _loc4_;
transitionDirection = _loc4_ > _loc3_ ? Number(1) : Number(-1);
transitionEndState = param1;
}
(_loc5_ = new StateChangeEvent(StateChangeEvent.CURRENT_STATE_CHANGE)).oldState = _currentState;
_loc5_.newState = param1;
dispatchEvent(_loc5_);
_currentState = param1;
}
}
public function get document() : Object
{
return _document;
}
public function get explicitMaxWidth() : Number
{
return _explicitMaxWidth;
}
public function set measuredMinWidth(param1:Number) : void
{
_measuredMinWidth = param1;
}
public function set cacheHeuristic(param1:Boolean) : void
{
}
public function set maxHeight(param1:Number) : void
{
explicitMaxHeight = param1;
}
public function setActualSize(param1:Number, param2:Number) : void
{
if(sizeChanged(_width,param1) || sizeChanged(_height,param2))
{
dispatchResizeEvent();
}
_width = param1;
_height = param2;
super.scaleX = param1 / measuredWidth;
super.scaleY = param2 / measuredHeight;
}
public function get cachePolicy() : String
{
return "";
}
public function set owner(param1:DisplayObjectContainer) : void
{
_owner = param1;
}
public function get descriptor() : UIComponentDescriptor
{
return _descriptor;
}
public function get includeInLayout() : Boolean
{
return _includeInLayout;
}
public function createReferenceOnParentDocument(param1:IFlexDisplayObject) : void
{
if(id && id != "")
{
param1[id] = this;
}
}
public function get measuredMinWidth() : Number
{
return _measuredMinWidth;
}
private function sizeChanged(param1:Number, param2:Number) : Boolean
{
return Math.abs(param1 - param2) > 1;
}
public function set isPopUp(param1:Boolean) : void
{
_isPopUp = param1;
}
public function initialize() : void
{
dispatchEvent(new FlexEvent(FlexEvent.PREINITIALIZE));
if(boundingBoxName && boundingBoxName != "" && boundingBoxName in this)
{
this[boundingBoxName].visible = false;
}
if(explicitSizeChanged)
{
explicitSizeChanged = false;
setActualSize(getExplicitOrMeasuredWidth(),getExplicitOrMeasuredHeight());
}
dispatchEvent(new FlexEvent(FlexEvent.INITIALIZE));
}
override public function set width(param1:Number) : void
{
explicitWidth = param1;
}
public function set percentHeight(param1:Number) : void
{
_percentHeight = param1;
notifySizeChanged();
}
public function set maxWidth(param1:Number) : void
{
explicitMaxWidth = param1;
}
private function buildStateMap() : void
{
var _loc1_:Array = null;
var _loc2_:int = 0;
_loc1_ = currentLabels;
stateMap = {};
_loc2_ = 0;
while(_loc2_ < _loc1_.length)
{
stateMap[_loc1_[_loc2_].name] = _loc1_[_loc2_];
_loc2_++;
}
}
public function deleteReferenceOnParentDocument(param1:IFlexDisplayObject) : void
{
if(id && id != "")
{
param1[id] = null;
}
}
public function owns(param1:DisplayObject) : Boolean
{
while(param1 && param1 != this)
{
if(param1 is IUIComponent)
{
param1 = IUIComponent(param1).owner;
}
else
{
param1 = param1.parent;
}
}
return param1 == this;
}
public function get measuredHeight() : Number
{
validateMeasuredSize();
return _measuredHeight;
}
public function setVisible(param1:Boolean, param2:Boolean = false) : void
{
super.visible = param1;
if(!param2)
{
dispatchEvent(new FlexEvent(!!param1 ? FlexEvent.SHOW : FlexEvent.HIDE));
}
}
public function get maxHeight() : Number
{
return !!isNaN(explicitMaxHeight) ? Number(10000) : Number(explicitMaxHeight);
}
public function set explicitMaxHeight(param1:Number) : void
{
_explicitMaxHeight = param1;
notifySizeChanged();
}
private function dispatchResizeEvent() : void
{
var _loc1_:ResizeEvent = null;
_loc1_ = new ResizeEvent(ResizeEvent.RESIZE);
_loc1_.oldWidth = oldWidth;
_loc1_.oldHeight = oldHeight;
dispatchEvent(_loc1_);
oldWidth = width;
oldHeight = height;
}
override public function get width() : Number
{
if(!isNaN(_width))
{
return _width;
}
return super.width;
}
public function get percentHeight() : Number
{
return _percentHeight;
}
public function set explicitMinWidth(param1:Number) : void
{
_explicitMinWidth = param1;
notifySizeChanged();
}
public function get isPopUp() : Boolean
{
return _isPopUp;
}
public function get explicitMaxHeight() : Number
{
return _explicitMaxHeight;
}
public function move(param1:Number, param2:Number) : void
{
this.x = param1;
this.y = param2;
if(param1 != oldX || param2 != oldY)
{
dispatchMoveEvent();
}
}
public function get toolTip() : String
{
return _toolTip;
}
public function set explicitWidth(param1:Number) : void
{
_explicitWidth = param1;
explicitSizeChanged = true;
notifySizeChanged();
}
public function get parentDocument() : Object
{
var _loc1_:IUIComponent = null;
var _loc2_:ISystemManager = null;
if(document == this)
{
_loc1_ = parent as IUIComponent;
if(_loc1_)
{
return _loc1_.document;
}
_loc2_ = parent as ISystemManager;
if(_loc2_)
{
return _loc2_.document;
}
return null;
}
return document;
}
public function set toolTip(param1:String) : void
{
var _loc2_:* = undefined;
_loc2_ = ApplicationDomain.currentDomain.getDefinition("mx.managers.ToolTipManager");
if(_loc2_)
{
_loc2_.mx_internal::registerToolTip(this,param1);
}
_toolTip = param1;
}
private function dispatchMoveEvent() : void
{
var _loc1_:MoveEvent = null;
_loc1_ = new MoveEvent(MoveEvent.MOVE);
_loc1_.oldX = oldX;
_loc1_.oldY = oldY;
dispatchEvent(_loc1_);
oldX = x;
oldY = y;
}
public function get explicitWidth() : Number
{
return _explicitWidth;
}
public function get measuredMinHeight() : Number
{
return _measuredMinHeight;
}
public function set measuredMinHeight(param1:Number) : void
{
_measuredMinHeight = param1;
}
}
}